<?php
class zona extends CI_Controller {
	var $titp='zona';
	var $url ='zona/';
	var $reg ='mision/';

	function index(){
		redirect($this->url.'filteredgrid');
	}

	function filteredgrid(){
		$this->load->library('rapyd');

		$filter = new datafilter_library();
		$filter->label = 'Zonas en las cuales funciona la mision del arbol en el Estado Merida';
		$filter->db->select('*');
		$filter->db->from('zonas');

		//$filter->field('input','nombre_zo'  ,'Nombre de la zona')->attributes(array('style' => 'width:170px'));
		//$filter->field('input','ubicacion'  ,'Ubicacion de la zona')->attributes(array('style' => 'width:170px'));

		//$filter->buttons('reset', 'search');
		//$filter->add_button(array('url'=>$this->reg.'back'));
		$filter->build();

		$uri = anchor($this->url.'dataedit/show/<raencode><#id#></raencode>','<#id#>');

		$grid = new datagrid_library();
		$grid->label = 'Lista de las zonas ';
		$grid->per_page = 40;
		$grid->cid = '';
		$grid->source($filter);

		$grid->column('nombre','Nombre de la zona',true)->url('zona/dataedit/show/{id}');
		$grid->column('caracteristicas','Ubicacion de la zona',true);
		$grid->column('precipitacion','Cantidad de precipitacion en la zona',true);
		$grid->column('temperatura','Temperatura de la zona',true);

		$grid->back_url = site_url($this->url.'mision');
		$grid->add_button(array('url'=>$this->url.'dataedit/create'));
		$grid->buttons('modify','save','undo','delete','back');
		$grid->build();

		$data['content'] = $filter->output.$grid->output;
		$data['head']    = $this->rapyd->head().script('jquery.js');
		$data['title']   = '';
		$this->load->view('view_ventanas_sola', $data);

	}

	function dataedit(){
		$this->load->library('rapyd');

		$edit = new dataedit_library();
		$edit->label = 'Zona';
		$edit->back_url = site_url($this->url.'filteredgrid');

		$edit->source('zonas');
		$edit->field('input','nombre','Nombre de la zona')->rule('trim|required');
		$edit->field('input','caracteristicas','Ubicacion de la zona')->rule('trim|required');
		$edit->field('input','precipitacion','Precipitacion de la zona')->rule('trim|required');
		$edit->field('input','temperatura','Temperatura de la zona')->rule('trim|required');

		$edit->buttons('modify','save','undo','delete','back');

		$edit->build();

		$data['head']    = $this->rapyd->head();
		$data['title']   = '<h1>Caracteristicas de la zona</h1>';
		$data['content'] = $edit;
		$this->load->view('view_ventanas_sola', $data);
	}

	
}

